#include "../ConnectionLibrary.h"
#include "ClientConnectionLibraryImpl.h"
#include "ServerConncetionLibraryImpl.h"

namespace AlgoTrading
{
	namespace ConnectionLibrary
	{

		std::auto_ptr<ClientConnectionLibrary> CreateClientConnectionLibraryInstance()
		{
			return std::auto_ptr<ClientConnectionLibrary>(new ClientConnectionLibraryImpl());
		}

		std::auto_ptr<ServerConnectionLibrary> CreateServerConnectionLibraryInstance(ClientConnectionAcceptorPtr acceptor, const std::string& address, const std::string& port)
		{
			return std::auto_ptr<ServerConnectionLibrary>(new ServerConnectionLibraryImpl(acceptor, address, port));
		}

		ClientHandlerBase::~ClientHandlerBase()
		{
		}
		
		ClientRequestProcessorPtr ClientHandlerBase::OnClientConnected(std::tr1::weak_ptr<ClientNotificationProcessor> client)
		{
			this->client = client;
			return GetGlientRequestProcessor(); 
		}
		void ClientHandlerBase::SendNotification(const AlgoTrading::Messages::NotificationMessage& message)
		{
			ClientNotificationProcessorPtr cl = client.lock();
			if (cl)
			{
				cl->SendNotification(message);
			}
		}
		void ClientHandlerBase::SendRequestResponse(const AlgoTrading::Messages::RequestResponse& message)
		{
			ClientNotificationProcessorPtr cl = client.lock();
			if (cl)
			{
				cl->SendRequestResponse(message);
			}
		}


		ClientRequestProcessor::~ClientRequestProcessor()
		{
		}

		ClientConnectionAcceptor::~ClientConnectionAcceptor()
		{
		}

		ClientConnectionLibrary::~ClientConnectionLibrary()
		{
		}

		ServerConnectionLibrary::~ServerConnectionLibrary()
		{
		}

		FeedConnector::~FeedConnector()
		{
		}

	}

}
